<?php

namespace app\api\controller;


use app\api\model\OrderCreate as OrderCreateModel;
use app\api\model\UserAddress as UserAddressModel;
use app\common\controller\Api;

/**
 * 拍卖订单提交接口
 */
class Ordercreate extends Api
{

    protected $noNeedRight = ['*'];


    //订单提交页
    public function calculate()
    {
        $auction_id = input('auction_id',0);

        $info = \app\api\model\Auction::get($auction_id);

        $address_list = UserAddressModel::where(['user_id'=>$this->auth->id])->select();

        $data = [
            'deposit'=>$info->deposit,
            'address_list'=>$address_list
        ];

        $this->success('',$data);
    }


    //订单提交
    public function create()
    {
        try {
            $param = input();
            $param['user_id'] = $this->auth->id;
            $auction_model = new OrderCreateModel();

            $list = $auction_model->ordercreate($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$list);
    }
}